Data Update
Making changes to existing data records to keep information up-to-date and relevant.
๐งฉ Overviewโ
Data Update workflows are responsible for modifying existing records in the system. These updates may reflect changes in user inputs, process corrections, business rule adjustments, or synchronization with external systems.
This process must ensure:
- Data integrity and auditability
- Minimal disruption to related workflows
- Controlled access and validation
๐ Common Update Scenariosโ
Use Case | Description |
---|---|
Update patient contact info | Phone/email changed |
Change billing status | Mark as paid, refunded, or canceled |
Modify test result values | Correction after review |
Adjust user permissions | Promote or demote access roles |
โ๏ธ SQL-Based Update Exampleโ
UPDATE patients
SET mobile = '9876543210', updated_at = NOW()
WHERE id = 105;
Always include updated_at
and, optionally, updated_by
to track changes.
๐งช Example: Status Transition for Lab Testโ
Scenario:โ
A lab test result moves from pending to approved after review.
UPDATE lab_results
SET status = 'approved', reviewed_by = 'Dr. Smith', reviewed_at = NOW()
WHERE id = 200 AND status = 'pending';
This ensures valid state transition (no redundant or invalid changes).
๐ฆ API Update Pattern (Express.js)โ
router.put("/patients/:id", async (req, res) => {
const id = req.params.id;
const { name, mobile } = req.body;
await db.query(
"UPDATE patients SET name = ?, mobile = ?, updated_at = NOW() WHERE id = ?",
[name, mobile, id]
);
res.json({ status: "updated" });
});
โ Validation Considerationsโ
- Check that the record exists before updating
- Validate incoming data types and formats
- Enforce business rules (e.g., no downgrading paid status)
- Prevent updates to restricted fields (e.g., ID, email after verification)
๐ Access Controlโ
Field | Access Rule Example |
---|---|
is_admin flag | Only super admins can update |
salary | Only HR roles can modify |
test_results | Only doctors or lab admins can edit |
Use role-based control to restrict editing capabilities.
๐ง Best Practicesโ
- Use PATCH for partial updates, PUT for full object replacement
- Always log what was changed, by whom, and when
- Perform updates in transactions if multiple tables are involved
- Add confirmation dialogs for UI-based changes
- Allow undo where applicable (versioning, history tables)
๐งพ Auditing and Loggingโ
Change Log Table Example:โ
{
"table": "patients",
"record_id": 105,
"changed_by": "admin_user",
"timestamp": "2025-05-22T10:15:00Z",
"changes": {
"mobile": {
"from": "9123456789",
"to": "9876543210"
}
}
}
Store this log separately or in a JSON column in the main table.
๐ UI Considerationsโ
- Inline editable fields for quick updates
- Save & Cancel buttons for user control
- Show change preview or summary before committing
- Disable fields that should not be edited
- Provide success/failure notifications
๐ Applications of Data Updateโ
Domain | Use Case |
---|---|
Healthcare | Update diagnosis or doctor assigned |
Finance | Correct transaction amount or category |
Logistics | Update delivery status or package location |
HR | Modify employee records or job title |
๐ Summaryโ
The Data Update workflow ensures that information remains accurate, relevant, and traceable. It should be implemented with validation, access control, and logging to maintain system trustworthiness and regulatory compliance.